package com.glsc.ngateway.common.base.converter.platform;

import com.alibaba.excel.util.CollectionUtils;
import com.glsc.ngateway.common.api.flowable.dto.FlowFormPartOutDetailDto;
import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.flow.cmdb.FlowFormPartOutDetail;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @author xuchang
 */
public class FlowFormPartOutDetailConverter {

    public static FlowFormPartOutDetailDto do2Dto(FlowFormPartOutDetail domain) {
        if (Objects.isNull(domain)) {
            return null;
        }
        FlowFormPartOutDetailDto dto = FlowFormPartOutDetailMapper.INSTANCE.do2Dto(domain);
        return dto;
    }

    public static List<FlowFormPartOutDetailDto> do2Dto(List<FlowFormPartOutDetail> domainList) {
        return CollectionUtils.isEmpty(domainList) ? java.util.Collections.emptyList() : domainList.stream().map(FlowFormPartOutDetailConverter::do2Dto).collect(Collectors.toList());
    }

    public static FlowFormPartOutDetail dto2Do(FlowFormPartOutDetailDto dto) {
        if (Objects.isNull(dto)) {
            return null;
        }
        FlowFormPartOutDetail domain = FlowFormPartOutDetailMapper.INSTANCE.dto2Do(dto);
        return domain;
    }

    public static List<FlowFormPartOutDetail> dto2Do(List<FlowFormPartOutDetailDto> dtoList) {
        return CollectionUtils.isEmpty(dtoList) ? java.util.Collections.emptyList() : dtoList.stream().map(FlowFormPartOutDetailConverter::dto2Do).collect(Collectors.toList());
    }

    @Mapper(componentModel = "spring")
    public interface FlowFormPartOutDetailMapper {

        FlowFormPartOutDetailMapper INSTANCE = Mappers.getMapper(FlowFormPartOutDetailMapper.class);

        FlowFormPartOutDetailDto do2Dto(FlowFormPartOutDetail domain);

        List<FlowFormPartOutDetailDto> do2Dto(List<FlowFormPartOutDetail> domain);

        FlowFormPartOutDetail dto2Do(FlowFormPartOutDetailDto dto);

        List<FlowFormPartOutDetail> dto2Do(List<FlowFormPartOutDetailDto> dto);
    }
}
